package com.lzy.webapi.response;

import com.lzy.framework.tools.date.DateStyle;
import com.lzy.framework.tools.date.DateUtils;

import java.io.Serializable;
import java.util.Calendar;

public class OrderYieldRatioResponse implements Serializable {
    private static final long serialVersionUID = -8659369173669004194L;

    /**
     * 返现时间(月份)
     */
    private Integer cashbackTime;

    /**
     * 返现时间描述
     */
    private String cashbackTimeDesc;

    /**
     * 返现比例
     */
    private String cashbackRatio;

    /**
     * 限制提现时间（天）
     */
    private Integer limitTime;

    /**
     * 日收益
     */
    private String dailyIncome;

    /**
     * 返现开始日期（格式：yyyy-MM-dd）
     */
    private String startDate;

    /**
     * 距首笔可提现天数
     */
    private Integer firstDays;

    /**
     * 状态：0-未返现 1-返现中 2-返现结束
     */
    private Integer status;

    /**
     * 龙币金额
     */
    private String price;

    public Integer getCashbackTime() {
        return cashbackTime;
    }

    public void setCashbackTime(Integer cashbackTime) {
        if (cashbackTime != null) {
            if (cashbackTime % 12 == 0) {
                cashbackTimeDesc = cashbackTime / 12 + "年";
            } else {
                cashbackTimeDesc = cashbackTime + "个月";
            }
        }
        this.cashbackTime = cashbackTime;
    }

    public String getCashbackTimeDesc() {
        return cashbackTimeDesc;
    }

    public String getCashbackRatio() {
        return cashbackRatio;
    }

    public void setCashbackRatio(String cashbackRatio) {
        this.cashbackRatio = cashbackRatio;
    }

    public Integer getLimitTime() {
        return limitTime;
    }

    public void setLimitTime(Integer limitTime) {
        this.limitTime = limitTime;
    }

    public String getDailyIncome() {
        return dailyIncome;
    }

    public void setDailyIncome(String dailyIncome) {
        this.dailyIncome = dailyIncome;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtils.StringToDate(startDate, DateStyle.YYYY_MM_DD));
        cal.add(Calendar.DATE, limitTime);
        if (cal.compareTo(Calendar.getInstance()) > 0) {
            firstDays = ((int) (cal.getTime().getTime() / 1000) - (int) (Calendar.getInstance().getTime().getTime() / 1000)) / 3600 / 24;
        } else {
            firstDays = 0;
        }
        this.startDate = startDate;
    }

    public Integer getFirstDays() {
        return firstDays;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }
}
